package compositionslist;

import javax.swing.*;
import java.awt.*;

public class CompositionsCellRenderer extends DefaultListCellRenderer {

    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        JLabel label =  (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        ScoredComposition scoredComposition = (ScoredComposition) value;

        label.setFont(new Font("Arial", 0, 14));
        label.setText(
                "<html>" + scoredComposition.getComposition() + " <b>(" + scoredComposition.getScores() + ")</b>"
        );

        return label;
    }
}
